const BaseController = require("./BaseController");

const UserModel = require("../../model/UserModel");
const EncAndDec = require("../../untis/EecAndDec");


class UserController extends BaseController {

   async login() {

        return this.display("login.html");
    }

    /**
     * 前台用户注册页面
     * @returns 
     */
    async userReg(){

        return this.display("userReg.html");
    }

    /**
     * 
     * @returns 用户注册后端逻辑
     */
    async handleReg(){

        //let name = this.req.post['name'];
        //let password = EncAndDec.md5(this.req.post['password']);
        //写入到数据库 你们完善  TODO
        return this.display("userReg.html");
    }

    async userList(){

        let user = new UserModel();

        try{
            let userList = await user.select();
            return JSON.stringify(userList);//就是把对象转成json格式
    
        }catch(err){
            console.log(err);
        }
        

    }

}
module.exports = UserController;